/*
 * Copyright (C) 2008-2012  Paulo Cesar Pereira de Andrade.
 *
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * Authors:
 *	Paulo Cesar Pereira de Andrade
 */

#ifndef _ewrite_h
#define _ewrite_h

#include "etypes.h"

/*
 * Types
 */
struct eformat {
    eint32_t	 width;
    eint32_t	 radix;
    eint32_t	 prec;		/* float precision */
    eint32_t	 left : 1;	/* align left */
    eint32_t	 aspc : 1;	/* print a space before positive numbers */
    eint32_t	 sign : 1;	/* always show number sign */
    eint32_t	 zero : 1;	/* pad with zeros */
    eint32_t	 read : 1;	/* output in format suitable for read back */
    eint32_t	 aflt : 1;	/* formatting a float64 */
    eint32_t	 uppr : 1;	/* uppercase */
    eint32_t	 eflt : 1;	/* exponent float */
    eint32_t	 gflt : 1;	/* general float */
};

/*
 * Prototypes
 */
extern void
init_write(void);

extern void
finish_write(void);

extern eword_t
eprint_ptr(estream_t *stream, eformat_t *format, eobject_t object);

extern eword_t
eprint_str(estream_t *stream, eformat_t *format, evector_t *vector);

extern eword_t
eprint_wrd(estream_t *stream, eformat_t *format, eword_t word);

extern eword_t
eprint_flt(estream_t *stream, eformat_t *format, efloat_t floating);

extern eword_t
eprint_rat(estream_t *stream, eformat_t *format, erat_t rat);

extern eword_t
eprint_mpz(estream_t *stream, eformat_t *format, empz_t integer);

extern eword_t
eprint_mpq(estream_t *stream, eformat_t *format, empq_t rational);

extern eword_t
eprint_mpr(estream_t *stream, eformat_t *format, empr_t floating);

extern eword_t
eprint_cdd(estream_t *stream, eformat_t *format, ecdd_t *dd);

extern eword_t
eprint_cqq(estream_t *stream, eformat_t *format, ecqq_t qq);

extern eword_t
eprint_mpc(estream_t *stream, eformat_t *format, empc_t c);

#endif /* _ewrite_h */
